package com.aolong.archives.core.sysmanage.action;

import com.aolong.archives.core.sysmanage.entity.RoleEntity;
import com.aolong.archives.core.sysmanage.service.IRoleService;
import com.rock.platform.action.BaseAction;
import com.rock.platform.entity.PageEntity;
import com.rock.platform.util.ActionJsonResult;
import com.rock.platform.util.JsonUtils;

public class RoleAction extends BaseAction {


	private static final long serialVersionUID = 1L;

	private IRoleService service;
	
	public String findAll() throws Exception
	{	
		PageEntity pageEntity = service.findAll(this.getActionParams());
		
		this.setJsonString(pageEntity.toString());
		
		return SUCCESS;
	}

	public String add() throws Exception
	{
		RoleEntity role = JsonUtils.getEntity(this.getJsonString(), RoleEntity.class);
		
		service.add(role);
		
		this.setJsonString(ActionJsonResult.getSuccessResult());
		
		return SUCCESS;
	}
	
	public String modify() throws Exception
	{
		RoleEntity role = JsonUtils.getEntity(this.getJsonString(), RoleEntity.class);
		
		service.modify(role);
		
		return SUCCESS;
	}
	
	public String remove() throws Exception
	{
		Object[] ids = JsonUtils.getObjectArray(this.getJsonString());
		
		service.remove(ids);
		
		return SUCCESS;
	}

	public IRoleService getService() {
		return service;
	}

	public void setService(IRoleService service) {
		this.service = service;
	}


}
